<?php

/// \todo this could do with some work, but I don't know Pascal.
class LuminousGrammarPascal extends LuminousGrammar

{
  public $case_insensitive = true;
  
  public $operators = array('(?<![a-zA-Z0-9_])and(?![a-zA-Z0-9_])', 
  '(?<![a-zA-Z0-9_])div(?![a-zA-Z0-9_])', 
    '(?<![a-zA-Z0-9_])in(?![a-zA-Z0-9_])',    
    
    '(?<![a-zA-Z0-9_])sh[lr](?![a-zA-Z0-9_])',        
    '(?<![a-zA-Z0-9_])not(?![a-zA-Z0-9_])',  
    '(?<![a-zA-Z0-9_])or(?![a-zA-Z0-9_])',
    '(?<![a-zA-Z0-9_])mod(?![a-zA-Z0-9_])',
    
    '(?<![a-zA-Z0-9_])xor(?![a-zA-Z0-9_])',
    
    '\+', '\*', '-', '\/', '=', '&[gl]t;', '=','!', '%', '&amp;', '\|','~',
    '\^', '\[', '\]');
    
  public $keywords = array(
    'absolute|abstract|all|and_then|array|as|asm',
    'begin|bindable',
    'case|class|const|constructor',
    'destructor|dispose|do|downto',
    'else|end|except|exit|export|exports',
    'false|file|finalization|finally|for|function',
    'goto',
    'if|implementation|import|inherited|initialization|inline|interface|is',
    'label|library',
    'module',
    'new|nil',
    'object|of|on|only|operator|or_else|otherwise',
    'packed|pow|procedure|program|property|protected',
    'qualified',
    'raise|record|repeat|restricted',
    'set',
    'then|threadvar|to|true|try|type',
    'unit|until|uses',
    'value|var|view|virtual',
    'while|with',
    'xor');   
  
  
  public $types = array('String', 'Integer', 'Real', 'Boolean', 'Character',
    'Byte(?:Int)?', 'Short(?:Int|Word|Real)', 'Word', 'Med(?:Int|Word)', 
    'Long(?:est)?(?:Int|Word|Real)', 'Comp', 'Smallint', 'SizeType',
    'Ptr(?:DiffType|Int|Word)',
    'Int64', 'Cardinal', 'QWord', 'ByteBool', 'WordBool', 'LongBool', 'Char');
    
  // http://www2.toki.or.id/fpcdoc/ref/refse64.html#x151-15700013.3
  public $functions = array('Abs', 'Addr', 'Append', 'Arctan', 'Assert',
    'Assign(?:ed)?', 'BinStr', 'Blockread', 'Blockwrite', 'Break', 'Chdir',
    'Chr', 'Close', 'Compare(Byte|Char|D?Word)', 'Concat', 'Copy', 'Cos',
    'CSeg', 'Dec', 'Delete', 'Dispose', 'DSeg', 'Eo(?:f|ln)', 'Erase',
    'Exclude', 'Exit', 'Exp', 'File(?:pos|size)', 'Fill(?:Byte|char|D?word)',
    'Flush', 'Frac', 'Freemem', 'Get(?:dir|mem|MemoryManager)', 'Halt',
    'HexStr', 'Hi', 'High', 'Inc(?:lude)?','Index(Byte|Char|D?Word)', 'Insert',
    'IsMemoryManagerSet', 'Int', 'IOresult', 'Length', 'Ln', 'Lo', 'LongJmp',
    'Low', 'Lowercase', 'Mark', 'Maxavail', 'Memavail', 'Mkdir', 'Move',
    'MoveChar0', 'New', 'Odd', 'OctStr', 'Ofs', 'Ord', 'Paramcount', 'Paramstr',
    'Pi', 'Pos', 'Power', 'Pred', 'Ptr', 'Random(?:ize)?', 'Read(?:ln)?',
    'Real2Double', 'Release', 'Rename', 'Reset', 'Rewrite', 'Rmdir', 'Round',
    'Runerror', 'Seek(?:Eof|Eoln)?', 'Seg', 'SetMemoryManager', 'SetJmp',
    'SetLength', 'SetString', 'SetTextBuf', 'Sin', 'SizeOf', 'Sptr', 'Sqrt?',  
    'SSeg', 'Str', 'StringOfChar', 'Succ', 'Swap', 'Trunc', 'Truncate',
    'Upcase', 'Val', 'Write(?:Ln)?');
    
    
  
  public function __construct()
  {
    $this->SetInfoLanguage('pascal');
    
    $this->SetInfoAuthor( 
    array('name'=>'Mark Watkinson', 'email'=>'markwatkinson@gmail.com',
    'website'=>'http://www.asgaard.co.uk'));
    $this->SetInfoVersion('0.5.0');          
    
    $this->delimited_types = array(
      luminous_generic_comment('{', '}'),
      luminous_generic_comment('(*', '*)'),
      luminous_generic_comment('//', "\n"),
      
      luminous_generic_sql_string("'"),
      luminous_generic_sql_string('"')
    );
    
    $this->SetSimpleTypeRules();
    
  }
  
  
  
}